package com.earnings.okhttputils.utils.utils;

import android.content.Context;

import com.earnings.okhttputils.utils.UrlConstant.Constant;
import com.earnings.okhttputils.utils.ui.dialog.PaymentDialog;
import com.earnings.okhttputils.utils.ui.dialog.PaytypeDialog;

/**
 * Created by HOHO on 2017/5/12.
 * 支付工具类
 */


public abstract class PayUtil {

    Context context;
    private String price;

    public PayUtil(Context context, String price) {
        this.price = price;
        this.context = context;
    }

    ;

    /*
    油卡话费 充值
     */
    public void showRechargeOil(String orderid,String info) {
        PaymentDialog dialog = new PaymentDialog( context, price, info, Constant.PAY_TYPE_WROK_OIL ) {
            @Override
            public void onSumbit(String type) {

                onSuccess( type, price );

            }


        };
        //dialog.showTreasurepay(); //这句话是开启财币支付
        dialog.setOrderid( orderid );

        dialog.show();
    }

    /*
    在线 充值
     */
    public void showRechargeOnline() {
        PaymentDialog dialog = new PaymentDialog( context, price, "在线充值", Constant.PAY_TYPE_WROK_RECHARGE ) {
            @Override
            public void onSumbit(String type) {
                onSuccess( type, price );

            }


        };
        dialog.cencelBanlance();
        dialog.show();
    }

    /*
  红包支付
   */
    public void showRed(String orderid) {
        PaymentDialog dialog = new PaymentDialog( context, price, "发送红包", Constant.PAY_TYPE_WROK_RED ) {
            @Override
            public void onSumbit(String type) {
                onSuccess( type, price );

            }


        };
        dialog.setOrderid( orderid );
        dialog.show();
    }
    /*
    红包支付
     */
    public void showShop(String orderid) {
        PaymentDialog dialog = new PaymentDialog( context, price,orderid, Constant.PAY_TYPE_WROK_SHOP ) {
            @Override
            public void onSumbit(String type) {
                onSuccess( type, price );

            }


        };
        dialog.setOrderid( orderid );
        dialog.show();
    }
    /*
升级高级绿心
 */
    public void showUpgrade() {
        PaymentDialog dialog = new PaymentDialog( context, price, "升级高级绿心", Constant.PAY_TYPE_WROK_UPGRADE ) {
            @Override
            public void onSumbit(String type) {
                onSuccess( type, price );
                ;
            }


        };
        dialog.setAimLevel( "advanced" );
        dialog.show();
    }

    /*
升级超级绿心
*/
    public void showUpgradeSuper() {
        PaymentDialog dialog = new PaymentDialog( context, price, "升级超级绿心", Constant.PAY_TYPE_WROK_UPGRADE ) {
            @Override
            public void onSumbit(String type) {
                onSuccess( type, price );
                ;
            }


        };
        dialog.setAimLevel( "ultra" );
        dialog.show();
    }

    /*
 转账
  */
    public void showTransfer(String phone, String paytype,String note) {
        PaymentDialog dialog = new PaymentDialog( context, price, "转账", Constant.PAY_TYPE_WROK_TRANSFER) {
            @Override
            public void onSumbit(String type) {
                onSuccess( type, price );
            }


        };
        dialog.setPhone( phone );
        dialog.setPaytype( paytype );
        dialog.setNote( note );
        if(paytype.equals( Constant.PAY_TYPE_BLANANCE ))
            dialog.sumbit();
        else
        dialog.createOrderPay();
        // dialog.show();
    }

    /*
        支付方式选择
         */
    private PaytypeDialog paytypeDialog;

    public void showPayChoose() {
        if (paytypeDialog == null) {
            paytypeDialog = new PaytypeDialog( context ) {
                @Override
                public void chooseItem(String typeid, String typename) {

                    onSuccess( typeid, typename );
                    dismiss();
                }
            };
       //     paytypeDialog.setPayButton( false );
        }
        paytypeDialog.show();
    }

    public abstract void onSuccess(String paytype, String info);
}
